import Vuex from './Cvuex'
import Vue from 'vue'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    counter: 1,
    a: 12
  },
  getters: {
    doubleCounter(state) {
      return state.counter * 2
    }
  },
  mutations: {
    add(state) {
      state.counter++
    }
  },
  actions: {
    add({commit}, a) {
      console.log("asyncadd", a);
      setTimeout(() => {
        commit('add')
      }, 1000)
    }
  },
  modules: {}
})
